import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:shenfuhui/config/config.dart';

import '../routers/routers.dart';

class HomeIndexTopLayout extends StatefulWidget {
  HomeIndexTopLayout({Key? key}) : super(key: key);

  @override
  HomeIndexTopLayoutState createState() => HomeIndexTopLayoutState();
}

class HomeIndexTopLayoutState extends State<HomeIndexTopLayout> {
  double opacity = 0;

  @override
  void initState() {
    super.initState();
  }

  upDateLayoutBg(double top) {
    setState(() {
      if (top > 0.8) {
        top = 1;
      }
      opacity = top;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: [
        Opacity(
          opacity: opacity,
          child: Container(
            height: 140.w,
            padding: EdgeInsets.only(top: 60.w, left: 25.w, right: 25.w),
            decoration: BoxDecoration(color: Colors.white),
          ),
        ),
        Container(
          height: 140.w,
          padding: EdgeInsets.only(top: 60.w, left: 25.w, right: 25.w),
          decoration: BoxDecoration(color: Colors.transparent),
          child: Row(
            children: [
              InkWell(
                child: Icon(
                  Icons.apps_outlined,
                  size: 50.w,
                  color: opacity < 0.5 ? Config.colorWhite : Config.colorText2,
                ),
                onTap: () {
                  Routes.navigateTo(context, Routes.productClassify);
                },
              ),
              Container(
                height: 46.w,
                width: 600.w,
                decoration: BoxDecoration(
                    color:
                        opacity < 0.5 ? Config.colorWhite : Config.colorDivider,
                    borderRadius: BorderRadius.circular(24.w)),
                padding: EdgeInsets.symmetric(horizontal: 20.w),
                margin: EdgeInsets.only(left: 25.w),
                child: Row(
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: [
                    Icon(
                      Icons.search,
                      size: 28.w,
                      color: Config.colorText3,
                    ),
                    Padding(
                      padding: EdgeInsets.only(left: 10.w),
                    ),
                    Text(
                      "请输入商品名称",
                      style: TextStyle(
                          fontSize: 22.sp,
                          height: 1.3,
                          color: Config.colorText3),
                    )
                  ],
                ),
              ),
            ],
          ),
        )
      ],
    );
  }
}
